<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{:config("app.app_name")}</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/css/layuimini.css?v=2.0.4.2" media="all">
    <link rel="stylesheet" href="__STATIC__/css/public.css?v=2.0.4.3" media="all">
    <link rel="stylesheet" href="__STATIC__/css/themes/default.css" media="all">
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>

    </style>
</head>
<body  >
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form layuimini-form" action="{:url('Menu/save')}" method="post">
            <div class="layui-form-item">
                <div class="layui-input-group layuimini-input-group">
                    <div class="layui-input-prefix layui-input-split layuimini-input-prefix">上级菜单</div>
                    <select name="pid" lay-verify="required">
                        <option value="0">一级菜单</option>
                        {foreach name="admin_menu_level_list" item="vo"}
                        <option value="{$vo.id}" {if condition="$admin_menu.pid==$vo.id"} selected="selected"{/if}>{neq name="vo.level" value="1"}|{php}for($i=1;$i<$vo['level'];$i++){echo ' ----';}{/php}{/neq} {$vo.title}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-group layuimini-input-group">
                    <div class="layui-input-prefix layui-input-split layuimini-input-prefix">菜单名称</div>
                    <input type="text" name="title" value="{$admin_menu.title}" required  lay-verify="required" placeholder="请输入菜单名称" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-group layuimini-input-group">
                    <div class="layui-input-prefix layui-input-split layuimini-input-prefix">规则</div>
                    <input type="text" name="name" value="{$admin_menu.name}" required  lay-verify="required" placeholder="请输入规则,如admin/AdminUser/save" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-group layuimini-input-group">
                    <div class="layui-input-prefix layui-input-split layuimini-input-prefix">图标（选填）</div>
                    <input type="text"  name="icon" value="{$admin_menu.icon|default='layui-icon-circle-dot'}" id="iconPicker" lay-filter="iconPicker"  placeholder="（选填）如：layui-icon-user" style="display:none;">


                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-group layuimini-input-group">
                    <div class="layui-input-prefix layui-input-split layuimini-input-prefix">类型</div>
                    <div class="layui-input-div">
                        <input type="radio" name="pattern" value="1" title="菜单" {if condition="$admin_menu.pattern==1"}checked="checked"{/if}>
                        <input type="radio" name="pattern" value="2" title="按钮" {if condition="$admin_menu.pattern==2"}checked="checked"{/if}>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-group layuimini-input-group">
                    <div class="layui-input-prefix layui-input-split layuimini-input-prefix">状态</div>
                    <div class="layui-input-div">
                        <input type="radio" name="status" value="1" title="显示" {if condition="$admin_menu.status==1"}checked="checked"{/if}>
                        <input type="radio" name="status" value="0" title="隐藏" {if condition="$admin_menu.status==0"}checked="checked"{/if}>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-group layuimini-input-group">
                    <div class="layui-input-prefix layui-input-split layuimini-input-prefix">排序</div>
                    <input type="number" name="sort" value="{$admin_menu.sort|default=0}" required  lay-verify="required" placeholder="请输入排序" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">

                    <button  class="layui-btn {:checkAutoBtn('admin/Menu/save')?'':'layui-hide'}" lay-submit lay-filter="submit">保存</button>

                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script src="__JS__/jquery.min.js"></script>
<script src="__STATIC__/layui/layui.js"></script>
<script src="__STATIC__/layui/lay-config.js?v=2.0.0" charset="utf-8"></script>
<script src="__JS__/common.js"></script>
<script>
    layui.config({
        base: '__STATIC__/layui/lay-module/'
    }).extend({
        iconPicker: 'iconPicker/iconPicker'
    });
    layui.use(['iconPicker'],function () {
        var form = layui.form;
        var layer = layui.layer;
        var iconPicker = layui.iconPicker;
        var util = layui.util;
        util.fixbar({
            top: true //返回顶部
            , css: { right: 15, bottom: 35 }
            , bgcolor: '#3b7cd8'
            , click: function (type) {

            }
        });

        iconPicker.render({
            // 选择器，推荐使用input
            elem: '#iconPicker',
            // 数据类型：fontClass/unicode，推荐使用fontClass
            type: 'fontClass',
            // 是否开启搜索：true/false，默认true
            search: true,
            // 是否开启分页：true/false，默认true
            page: false,
            // 每页显示数量，默认12
            limit: 15,
            // 每个图标格子的宽度：'43px'或'20%'
            cellWidth: '43px',
            // 点击回调
            click: function (data) {

                $("#iconPicker").val(data.icon)
            },
            // 渲染成功后的回调
            success: function(d) {

            }
        });
        iconPicker.checkIcon('iconPicker', "{$admin_menu['icon']}");
        // 提交事件
        form.on('submit(submit)', function(data){
            var field = data.field; // 获取表单字段值
            Ajax('/admin/Menu/'+"{$admin_menu['id']}",'put',$(data.form).serialize(),
                success=function (info) {
                    if (info.code === 1) {
                        layer.confirm(info.msg, {icon: 1,btn: ['返回列表'],cancel: function(){
                                window.location.href = ""
                            }}, function(){
                            layer.close(layer.index);
                            window.parent.location.reload();
                        });
                    }else{
                        layer.msg(info.msg)
                    }
                },error=function(e){
                    console.log(e,22)
                }
            );
            return false; // 阻止默认 form 跳转
        });
    });
</script>
</body>
</html>
